package com.origin.app.page.main

import android.Manifest
import android.content.Intent
import androidx.fragment.app.Fragment
import com.amap.api.location.AMapLocationClient
import com.amap.api.location.AMapLocationClientOption
import com.origin.app.MyApplication
import com.origin.app.R
import com.origin.app.page.login.LoginActivity
import com.origin.app.page.main.fragment.home.HomeFragment
import com.origin.app.page.main.fragment.mine.MineFragment
import com.origin.app.page.map.AppMapActivity
import com.origin.baselibrary.activity.style.ViewPagerActivity
import com.origin.baselibrary.fragment.getInstance
import com.origin.utils.permissions.OnPermissionPageCallback
import com.origin.utils.permissions.PermissionsUtils

class MainViewPagerActivity : ViewPagerActivity(isSafeDis = false) {

    companion object {
        fun launcher() {
            MyApplication.getInstance().getCurrentActivity()?.apply {

                val self = this
                AMapLocationClient.updatePrivacyShow(this, true, true)
                AMapLocationClient.updatePrivacyAgree(this, true)
                PermissionsUtils.simpleRequestPermissions(this,
                    Manifest.permission.ACCESS_FINE_LOCATION,
                    Manifest.permission.ACCESS_COARSE_LOCATION,
                    Manifest.permission.ACCESS_LOCATION_EXTRA_COMMANDS,
                    onPermissionPageCallback = object : OnPermissionPageCallback {
                        override fun onGranted(permissions: MutableList<String>?) {

                            val mLocationOption = AMapLocationClientOption();
                            mLocationOption.locationMode =
                                AMapLocationClientOption.AMapLocationMode.Hight_Accuracy
                            mLocationOption.interval = 2000;


                            val intent = Intent(self, MainViewPagerActivity::class.java)
                            startActivity(intent)
                        }

                        override fun onDenied(permissions: MutableList<String>?) {

                        }

                    })

            }
        }
    }
    override fun setSelectorUi(
        iconUnselectIds: MutableList<Int>,
        iconSelectIds: MutableList<Int>,
        titles: MutableList<String>,
        fragments: MutableList<Fragment>
    ) {

        iconSelectIds.add(R.mipmap.icon_app_launcher)
        iconSelectIds.add(R.mipmap.icon_app_launcher)
        iconUnselectIds.add(R.mipmap.icon_app_launcher)
        iconUnselectIds.add(R.mipmap.icon_app_launcher)

        titles.add("首页")
        titles.add("我的")

        fragments.add(HomeFragment::class.java.getInstance("首页"))
        fragments.add(MineFragment::class.java.getInstance("隐私保护"))
    }

    override fun pageLogical() {

    }
}